Socket
Socket
Sign inDemoInstall

vscode-jsonrpc

Package Overview
Dependencies
Maintainers
7
Versions
130
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vscode-jsonrpc

A json rpc implementation over streams


Version published
Weekly downloads
2.9M
increased by1.71%
Maintainers
7
Weekly downloads
 
Created

What is vscode-jsonrpc?

The vscode-jsonrpc package provides a framework for implementing JSON-RPC based communication. It is primarily used for building language servers and other tools that need to communicate over JSON-RPC.

What are vscode-jsonrpc's main functionalities?

Creating a JSON-RPC connection

This code demonstrates how to create a JSON-RPC connection using the vscode-jsonrpc package. It spawns a child process and sets up a message connection using the standard input and output streams of the child process.

const { createMessageConnection, StreamMessageReader, StreamMessageWriter } = require('vscode-jsonrpc');
const { spawn } = require('child_process');

const childProcess = spawn('node', ['path/to/your/server.js']);

const connection = createMessageConnection(
  new StreamMessageReader(childProcess.stdout),
  new StreamMessageWriter(childProcess.stdin)
);

connection.listen();

Sending a request

This code demonstrates how to send a request over a JSON-RPC connection. The sendRequest method sends a request with a specified method and parameters, and returns a promise that resolves with the response.

connection.sendRequest('example/request', { param1: 'value1' }).then(response => {
  console.log('Received response:', response);
});

Handling notifications

This code demonstrates how to handle notifications over a JSON-RPC connection. The onNotification method registers a handler for notifications with a specified method.

connection.onNotification('example/notification', params => {
  console.log('Received notification:', params);
});

Handling requests

This code demonstrates how to handle requests over a JSON-RPC connection. The onRequest method registers a handler for requests with a specified method, and the handler returns a response.

connection.onRequest('example/request', params => {
  return { result: 'response' };
});

Other packages similar to vscode-jsonrpc

FAQs

Package last updated on 21 May 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc